package dome1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-06-22
 * Time: 20:08
 */
class MyArray2<T> {
    //这种创建数组常用,java官方自己也是这样!!!
    public Object[] obj = new Object[3];

    public T getPos(int pos) {
        return (T)obj[pos];
    }
    public void setObj(int pos,Object val) {
        obj[pos] = val;
    }
}
public class Test2 {
    public static void main(String[] args) {
        MyArray2<Integer> myArray2 = new MyArray2<>();
        myArray2.setObj(0,10);
        myArray2.setObj(1,20);
        myArray2.setObj(2,30);

        Integer a = myArray2.getPos(0);
        System.out.println(a);
    }
}
